package com.example.rpcserver.service;

import com.example.UserProto;
import com.example.UserServiceGrpc;
import io.grpc.stub.StreamObserver;
import net.devh.boot.grpc.server.service.GrpcService;

@GrpcService
public class UserServiceImpl extends UserServiceGrpc.UserServiceImplBase {

    @Override
    public void login(UserProto.UserRequest request, StreamObserver<UserProto.UserResponse> responseObserver) {
        String name = request.getName();
        System.out.println("grpc spring boot name:" + name);

        UserProto.UserResponse response = UserProto.UserResponse.newBuilder()
                .addResult("1")
                .addResult("2")
                .setData(UserProto.UserDataResponse.newBuilder().setContent("grpc spring boot").build())
                .build();
        responseObserver.onNext(response);
        responseObserver.onCompleted();

    }
}
